<script setup lang="ts">
import moment from 'moment'
import { onBeforeUnmount, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
let router = useRouter()
let time = ref(moment().format('YYYY年MM月DD日 hh:mm:ss'))
let timer = ref()
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format('YYYY年MM月DD日 hh:mm:ss')
  }, 1000)
})
onBeforeUnmount(() => {
  clearInterval(timer.value)
})
const toHome = () => {
  router.push('/')
}
</script>

<template>
  <div class="top">
    <div class="tLeft"><span @click="toHome">首页</span></div>
    <div class="tMiddle">
      <p>智慧旅游可视化大数据展示平台</p>
      <div class="img">
        <span>平台高峰预警信息（2条）</span>
      </div>
    </div>
    <div class="tRight">
      <span>统计报告</span>
      <p>当前时间: {{ time }}</p>
    </div>
  </div>
</template>

<style scoped lang="scss">
.top {
  display: flex;
  .tLeft {
    height: 40px;
    flex: 1.6;
    background: url('../images/dataScreen-header-left-bg.png') no-repeat;
    background-size: cover;
    span {
      display: block;
      width: 135px;
      height: 100%;
      background: url('../images/dataScreen-header-btn-bg-l.png') no-repeat;
      background-size: cover;
      color: #29fcff;
      float: right;
      text-align: center;
      line-height: 40px;
      font-size: 20px;
      cursor: pointer;
    }
  }
  .tMiddle {
    height: 74px;
    flex: 2.4;
    background: url('../images/dataScreen-header-center-bg.png') no-repeat;
    background-size: cover;
    position: relative;
    p {
      text-align: center;
      line-height: 74px;
      font-size: 32px;
      color: #29fcff;
    }
    .img {
      width: 622px;
      height: 44px;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      background: url('../images/dataScreen-header-warn-bg.png') no-repeat;
      background-size: cover;
      text-align: center;
      line-height: 44px;
      color: white;
    }
  }
  .tRight {
    height: 40px;
    flex: 1.6;
    background: url('../images/dataScreen-header-right-bg.png') no-repeat;
    background-size: cover;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #29fcff;
    span {
      width: 135px;
      height: 100%;
      background: url('../images/dataScreen-header-btn-bg-r.png') no-repeat;
      background-size: cover;
      text-align: center;
      line-height: 40px;
      font-size: 20px;
    }
    p {
      padding-right: 50px;
    }
  }
}
</style>
